<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件

function ArrayKey(& $data){
	if(!empty($data)){
		if(is_array($data)){
			$new_arr = array();
			foreach($data as $k=>$v){
				$new_arr[$v['id']] = $v;
			}
			$data = $new_arr;
		}
	}
	return $data;	
}
/**
 * 数组转化成字符串
 * $arr 数组
 * $tb 间隔符
**/
function Array2String($arr,$tb=','){
	$data=$tb;
	if(is_array($arr)){
		$arr = array_filter($arr);
		$arr = array_values($arr);
		$data .= implode($tb,$arr);
		$data.=$tb;
	}
	return $data;
}
/**
 * 字符串转化成数组
 * $word 字符串
 * $tb 间隔符
**/
function String2Array($word,$tb=','){
	$all = explode($tb,$word);
	$all = array_filter($all);
	$all = array_values($all);
	return $all;
}
/**
 * 换行符切换数组
**/
function nl2array($str){
	$_group_lists = explode("\n",$str);

	$group_lists = array();
	foreach($_group_lists as $v){
		$v = str_replace(array("\r\n", "\r", "\n"), "", $v);
		if($v != "" && $v != "\r"){
			$group_lists[] = trim($v);
		}
	}
	return $group_lists;
}
